<?php
/**
 * RUBIK IT Solution & Development ltd.
 *
 * PROJECT		: Rubik Ultimate
 * @version 	: 1.1
 * COPYRIGHT	: 2008
 * ------------------------------------------------------
 * 
 * [GENERAL INFO OF THIS FILE] 
 *
 * @author			hoadn <hoadn@rubik.com.vn>
 * @access			[public/private]
 * @package		 [package name]
 *
 * Created on	:Sep 19, 2008
 */

// no direct access
defined ( '_FW_EXEC' ) or die ( 'Restricted access' );

RCoreImporter::cls('html.fieldInfo.BasicHtmlFieldInfo');
RCoreImporter::cls('html.BasicHtmlImageUploadControl');

class PictureHtmlFieldInfo extends BasicHtmlFieldInfo {
	
//	/**
//	 * @var BasicHtmlImageUploadControl
//	 */
//	var $_imgUploadControl = null;
//	
//	/**
//	 * Constructor
//	 *
//	 * @param string $basicName
//	 */
//	function __construct($basicName, $linkRule = null) {
//		parent::__construct($basicName, $linkRule);
//		
//		$this->_hasTblOrder = false;
//		$this->_imgUploadControl = new BasicHtmlImageUploadControl($basicName);
//	}
//	
//	/**
//	 * Set the value
//	 *
//	 */
//	function setValue($valueOrArrayContain = null) {
//		$ctrl = $this->_imgUploadControl;
//		$ctrl->setInputName($this->_fieldName);
//		$ctrl->setValue($valueOrArrayContain);
//	}
//	
//	/**
//	 * Get the value
//	 * 
//	 * @return string
//	 */
//	function getValue() {
//		$ctrl = $this->_imgUploadControl;
//		return $ctrl->getValueWithoutUrl();
//	}
//	
//	/**
//	 * For checking if we need to create the filter header
//	 * NOTE: please override in case special treat
//	 *
//	 * @return boolean
//	 */
//	function shouldCreateFilter() {
//		return false;
//	}
//	
//	/**
//	 * Function for geting the html for inputing data
//	 *
//	 * @abstract 
//	 * @return string
//	 */
//	function getHtmlInputData($dataType = '', $extAttribute = '') {
//		$ctrl = $this->_imgUploadControl;
//		$extAttribute .= $this->buildValidateHtmlAttribute($dataType);
//		return $ctrl->createUploadFormHtml($extAttribute);
//	}
	
	/**
	 * Function for geting the html for previewing data
	 *
	 * @abstract 
	 * @return string
	 */
	function buildHtmlPreviewData($extAttributes = '', $key=null, $dataType ='S') {
		$link = $this->getValue();
		if (!(strpos($link, 'http') === 0 || strpos($link, '/') === 0)) {
			$link = SYS_ROOT_URL.$link;
		}
		$ctrl = $this->_imgUploadControl;
		$htmlData = "<img src=\"{$link}\" {$extAttributes}/>";
		return $htmlData;
	}
	
	/**
	 * For checking if we need to create the filter header
	 * NOTE: please override in case special treat
	 *
	 * @return boolean
	 */
	function shouldCreateFilter() {
		return false;
	}
}
?>